﻿using System;
using System.Collections.Generic;

using EDP.Common.Model;
using EDP.Framework;
using EDP.Organization;

namespace School.Model.Organization
{
    /// <summary>
    /// 组织对象
    /// </summary>
    [ModelEnitity(TableName = "t_sys_organization_unit", KeyName = "ID")]
    public class OrganizationModel: ModelPermissionBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public OrganizationModel() {
            this.SetDefaultQuerySQL(@"select *
        from (select t.ID
                    ,t.Name
                    ,t.Levels
                    ,t.PropertyId
                    ,t.ParentId
                    ,t.Code
                    ,t.FullCode
                    ,t.OrganizationId
			        ,a.Numbers TypeNumbers
			        ,a.Name TypeName
		        from t_sys_organization_unit t
		        left join t_sys_organization_type a on t.OrganizationTypeId = a.ID) tab");
        }

        /// <summary>
        /// 主键ID
        /// </summary>
        [ModelEnitity(ColumnName = "ID")]
        public string ID { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 级别
        /// </summary>
        public int? Levels { get; set; }

        /// <summary>
        /// 性质ID
        /// <para>对应组织单元性质枚举<see cref="OrganizationUnitPropertyEnum"/></para>
        /// </summary>
        public int? PropertyId { get; set; }

        /// <summary>
        /// 上级组织ID
        /// </summary>
        public string ParentId { get; set; }

        /// <summary>
        /// 编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 全编码
        /// </summary>
        public string FullCode { get; set; }

        /// <summary>
        /// 所属机构ID
        /// </summary>
        public string OrganizationId { get; set; }

        /// <summary>
        /// 类型编号
        /// </summary>
        public string TypeNumbers { get; set; }

        /// <summary>
        /// 类型名称
        /// </summary>
        public string TypeName { get; set; }

        /// <summary>
        /// 组织路径列表
        /// </summary>
        public List<OrganizationModel> OrganizationPathList { get; set; } = new List<OrganizationModel>();
    }
}
